import type { Pagination } from "@/types/views/friend"
import type { FormInstance, FormRules } from "element-plus"
export class BaseForm<T extends object> {
    [key: string]: any
    ref: FormInstance | null = null
    data: T & Pagination = {} as T & Pagination
    rules: FormRules<T> = {}
    constructor(options?: { data?: T, rules?: FormRules<T>, [key: string]: any }) {
        this.data.page = 1
        this.data.pageSize = 10
        if (!!options) {
            for (const key in options) {
                if (Object.prototype.hasOwnProperty.call(options, key)) {
                    this[key] = options[key]
                }
            }
        }
    }
    reset = () => {
        this.ref?.resetFields()
    }
    validate = async () => {
        return await this.ref?.validate()
    }
}